package com.heartech.prediciton_wx.utils.verify;


import com.heartech.prediciton_wx.utils.Exception.AesException;
import com.heartech.prediciton_wx.utils.verify.SHA1;

public class SignatureUtil {
    public static boolean verifyUrl(String msgSignature, String timeStamp, String nonce) throws AesException {
        String TOKEN = "heartech";
        // 使用token, timeStamp, 和 nonce生成SHA1签名
        try{
            String generatedSignature = SHA1.getSHA1(TOKEN, timeStamp, nonce);
            System.out.println("结果为" + generatedSignature);
            System.out.println(generatedSignature.equals(msgSignature));
            // 比较生成的签名与微信发送的签名
            return generatedSignature.equals(msgSignature);
        }catch (Exception e){
            throw new AesException(AesException.VALIDATE_SIGNATURE_ERROR);
        }
    }
}

